<div class="fsh-pop">
    <div id="add_form" class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>名称</label>
            <div class="layui-input-block">
                <input type="text" name="roleName" lay-verify="required" placeholder="请输入关键字" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>别名</label>
            <div class="layui-input-block">
                <input name="roleKey" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>上级名称</label>
            <div class="layui-input-block">
                <select id="selectID" lay-filter="parent" name="parentId">

                </select>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    layui.use(['form'], function () {
        var form = layui.form;
        $('#selectID').html();
        $.ajax({
            url: context + '/api/sysrole/list',
            dataType: 'json',
            type: 'get',
            success: function (data) {
                if (data != undefined && data != null && data != "") {
                    var list = data.data;
                    var html = "<option value=''>请选择上级角色</option>";
                    for (var i = 0; i < list.length; i++) {
                        html += "<option value=" + list[i]["role_id"] + ">" + list[i]["roleName"] + "</option>";
                    }
                    $("#selectID").append(html);
                    form.render("select");
                }
            }
        });

    });

</script>